﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/25/2009
 * Time: 9:25 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Miming.Model;
using Miming.Util;

namespace Miming.Gui
{
	/// <summary>
	/// Description of ItemForm.
	/// </summary>
	public partial class ItemForm : BaseForm
	{
		public ItemForm() : this(new Item())
		{
			
		}
		
		public ItemForm(Item i)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			SwfUtility.SetupComboBox(comboBoxType, ApplicationUtility.ItemTypes, "Name", "Name");
			
			i.Observers.Clear();
			foreach (ItemType t in comboBoxType.DataSource as IList<ItemType>) {
				i.Observers.Add(t.Control as IObserver);
			}
			i.NotifyObservers();
		}
		
		void ComboBoxTypeSelectedIndexChanged(object sender, EventArgs e)
		{
			ItemType type = (comboBoxType.DataSource as List<ItemType>)[comboBoxType.SelectedIndex];
			panel1.Controls.Clear();
			panel1.Controls.Add(type.Control);
			label1.Text = type.Description;
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
